package guo.xungenguser.controller;

import guo.xungengcommon.utils.R;
import guo.xungengcommon.vo.TokenGetUser;
import guo.xungengcommon.vo.UserVo;
import guo.xungenguser.dao.UserDao;
import guo.xungenguser.entity.User;
import guo.xungenguser.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/user")
public class UserBasicController {

    @Autowired
    UserService userService;

    /**
     * weibo登录 保存用户
     * 若未登录 则根据token查询用户信息 保存数据库
     * 若已经登录 则刷新数据库的token字段
     * @param tokenGetUser
     * @return
     */
    @ResponseBody
    @PostMapping("/save")
    public R saveUser(@RequestBody TokenGetUser tokenGetUser){
        R r = userService.saveUser(tokenGetUser);
        return r;
    }

    @ResponseBody
    @PostMapping("/gitee/save")
    public R saveGiteeUser(@RequestBody UserVo userVo){
        R r = userService.saveGiteeUser(userVo);
        return r;
    }

}
